#ifndef DBMANAGER_H
#define DBMANAGER_H
#include <QGlobalStatic>

#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlRecord>
#include <QSqlField>
#include <QMap>

class dbManager
{
public:
    static dbManager& getInstance() {
        static dbManager instance; // 在首次调用时初始化
        return instance;
    }
private:
    dbManager();
public:
    bool openDB(const QString& fileName,QString& uuid,QString& msg);
    bool selectDataMultiple(const QString& sql,const QString& uuid,QString& msg,QJsonArray& jsonArray);
    bool selectDataSingle(const QString& sql,const QString& uuid,QString& msg,QJsonObject& jsonObject);
    bool addData(const QString& sql,const QString uuid,QString& msg);
    bool deleteData(const QString& sql,const QString uuid,QString& msg);
    bool updateData(const QString& sql,const QString uuid,QString& msg);
protected:
    QString generaterUUID();
private:
    QMap<QString,QSqlDatabase> dbMap;


};
#define dbManagerInstance dbManager::getInstance()
#endif // DBMANAGER_H
